const mongoose=require("mongoose");
const Schema=mongoose.Schema;
mongoose.connect("mongodb://127.0.0.1/Message");
mongoose.connection.on('connected',  () =>{
    console.log('Mongoose success' );
});
const userSchema=new Schema({     //用户表
    username:{type:'string', require:'true'},
    password:{type:'string', require:'true'},
    images:{type:'string', require:'true'}
});
const  messageSchema=new Schema({   //留言表
    userId:{type:'ObjectId', require:'true',ref: 'user'},
    message:{type:'string', require:'true'},
})
const  messageModel=mongoose.model('message',messageSchema);
const userModel=mongoose.model('user',userSchema);
//insert()
// function insert() {
//     let user=new userModel({              //增加用户
//     username:"Admin",
//     password:123
//     }).save((err,data)=>{
//     if(err){
//       console.log(err);
//     }
// });
// }
module.exports={UserModel:userModel,MessageModel:messageModel}








